package rsax

import (
	"encoding/base64"
	"testing"

	"gitcode.com/yeyixianyang/gokits/encoder"
)

func TestEncrypt(t *testing.T) {
	pubKey, err := PemPublicKey([]byte(publicKeyStr))
	if err != nil {
		t.Error(err)
	}

	cipher, err := Encrypt(pubKey, []byte(plainText))
	if err != nil {
		t.Fatal(err)
	}

	t.Log(base64.StdEncoding.EncodeToString(cipher))
}

func TestEncryptWithEncoder(t *testing.T) {
	pubKey, err := PemPublicKey([]byte(publicKeyStr))
	if err != nil {
		t.Error(err)
	}

	cipher, err := EncryptWithEncoder(pubKey, []byte(plainText), &encoder.Base64Encoder)
	if err != nil {
		t.Error(err)
	}

	t.Log(cipher)
}

func TestDecrypt(t *testing.T) {
	priKey, err := PemPrivateKey([]byte(privateKeyStr))
	if err != nil {
		t.Error(err)
	}

	cipher, err := base64.StdEncoding.DecodeString(cipherText)
	if err != nil {
		t.Error(err)
	}

	plain, err := Decrypt(priKey, cipher)
	if err != nil {
		t.Error(err)
	}

	t.Log(string(plain))
}

func TestDecryptWithEncoder(t *testing.T) {
	priKey, err := PemPrivateKey([]byte(privateKeyStr))
	if err != nil {
		t.Error(err)
	}

	plain, err := DecryptWithEncoder(priKey, cipherBase64, &encoder.Base64Encoder)
	if err != nil {
		t.Error(err)
	}

	t.Log(string(plain))
}

func TestEncryptOAEPWithSha256(t *testing.T) {
	pubKey, err := PemPublicKey([]byte(publicKeyStr))
	if err != nil {
		t.Error(err)
	}

	cipher, err := EncryptOAEPWithSha256(pubKey, []byte(plainText))
	if err != nil {
		t.Error(err)
	}

	t.Log(base64.StdEncoding.EncodeToString(cipher))
}

func TestEncryptOAEPWithSha256AndEncoder(t *testing.T) {
	pubKey, err := PemPublicKey([]byte(publicKeyStr))
	if err != nil {
		t.Error(err)
	}

	cipherText, err := EncryptOAEPWithSha256AndEncoder(pubKey, []byte(plainText), &encoder.Base64Encoder)
	if err != nil {
		t.Error()
	}

	t.Log(cipherText)
}

func TestDecryptOAEPWithSha256(t *testing.T) {
	priK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AWQVLC82nLgN4hvyvFZ3MUlg85PneRs="

	cipher, err := base64.StdEncoding.DecodeString(cipherBase64)
	if err != nil {
		t.Error(err)
	}

	plain, err := DecryptOAEPWithSha256(priKey, cipher)
	if err != nil {
		t.Error(err)
	}

	t.Log(string(plain))
}

func TestDecryptOAEPWithSha256AndEncoder(t *testing.T) {
	priKey, err := PemPrivateKey([]byte(privateKeyStr))
	if err != nil {
		t.Error(err)
	}

	plainText, err := DecryptOAEPWithSha256AndEncoder(priKey, "BB4Tm8Dk0kD7fODe82tzSylxNyTP07Mte7svWEuED+MhQ+svB37OnsKjdbusToeYYntH1w3ezfzU5faN9qZCFZTiL8ZHgK5ffLdnidAWA6W11a1q/jvHv6Wh+Ddjep+fUv7MYeieAxSMVhhTLfThPg/AesX35uzOsIe7G08d5Q05CI8ru+IQvUfvJYY2FinIQr16EKJRqolUB24aOID8c+72Td7cKN0X2uEaJ3RJvTG/ZUskfPbehio+TP7T851dio2sR+6djgROMbmR1g82yLDj197lB7X8UvGp4agg5LdvN7lurAn23TO/KeAZI36HreAGocfsuy6UrTZCzQ3Qcxy/3NJf2W1KOqzcJVcy+Uq2mkIhafYlEdfdsRyCo6qNROALrcwGQ1LLY1YZIzt1MpNijZbaBHv9I2aYO0TB8nfCk485PsjMqixKIPLT4EuYHh6n9A5Nqhw9bqGCIlyX1lCmNW0JoRUvXd7L+1h4GBzPslYRCVYEiiBptyCEB22rB3l7f5A0q/2/DQNiB3rZNxmqQsfA4N+bLPmFn9Cfz9MPaf3zO54EhQtRPEQPUGI/WbF+wBmlKuj/CEZyG8JzfHb7QNgFvl7/WWOvETXiA4QN1wzbBj0sJMXryiq7EpEe2ZfsSYNIKFSvqK0c94YFJoOZdUCOOoNudVsz0zqSW8hvcE5xYvNTDKEww9k+iumzB1VRKuvCK0GgQaJAqk14nYY6EoRyH3lyOecPNFHGvYhU7cPTGfh8F+41clbwcjVw4Y2yxZuQ9j9gW4rOl861K5e2gEoKjCP4/XnHRHlOVJvKMmj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ykY8Dqp2PoggwMQa29ch2ENtrAknV/c20Yc1YCbj+ilqxyOFrszfmYfZmsgN8pdQSeqxY3WXgxLL9KYwC/Gao6s7gW0csWEG57Ugnu99cvv4Hz2anK6+ygJcxYfkFl4KfTsXPDiSxV3T1HxiRAQlPbed/KG1iv55tIYuJQwufRN8lrNBwvXciYDrfYyp8fYjdVM6uc/jlnrwvhHVk7lcmXLFYg=", &encoder.Base64Encoder)
	if err != nil {
		t.Error(err)
	}

	t.Log(string(plainText))
}

func TestEncryptOAEPWithSha1(t *testing.T) {
	pubKey, err := PemPublicKey([]byte(publicKeyStr))
	if err != nil {
		t.Error(err)
	}

	cipher, err := EncryptOAEPWithSha1(pubKey, []byte(plainText))
	if err != nil {
		t.Error(err)
	}

	t.Log(base64.StdEncoding.EncodeToString(cipher))
}

func TestEncryptOAEPWithSha1AndEncoder(t *testing.T) {
	pubKey, err := PemPublicKey([]byte(publicKeyStr))
	if err != nil {
		t.Error(err)
	}

	cipherText, err := EncryptOAEPWithSha1AndEncoder(pubKey, []byte(plainText), &encoder.Base64Encoder)
	if err != nil {
		t.Error(err)
	}

	t.Log(cipherText)
}

func TestDecryptOAEPWithSha1(t *testing.T) {
	priKey, err := PemPrivateKey([]byte(privateKeyStr))
	if err != nil {
		t.Error(err)
	}

	cipherBase64 := "dtQQSrHRp406jnMtol6CIFI3a2wT9qhiyfvHwuSWMwfbpp7L60RKMv2IppAyZ5JkDPMFJ2VGQHibTJycclgNbwXV5UktbPTABcFj2/OuXw/hQHrTH+rEDKFrFQg4jW4zIcmqpGkiaAbeqdpIMqh1vFZqsGbiPC3/JP+QOMeVjAAXo/S4VjgXHj34D4LPSDtBdd8lOq3TlopmjJVqTnyVmA79jiioYNs6wDuX/3vwEXp5HhlboUPstMTDWPfis5t2DMTvAQDCk9co0Glg5yjGxZqLgC9OztbDA08KomPg9Wo0aCz+FOGxV9KHDtBoKsRjKsX/Sb6JUggcX4efCL5iCmI/lb+Smi1A4kdQiFuUgwg9+l4Db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gvJY+A/MWyHaRUyazR4/xcqllqPtN2HQX5ta+r0ORVzCfgzRbqxWN3W7CCfWNLhj5eUHLMKuqvMPMzYh85QkbJbVBg2SuOe+5L1exFdtNA+TAinfQfmokpwiTzI4YyW2eomK3Cic/O5EKFMVodFJ+29qIMbwCjVfq+0lmkgpwLXtUkKB3GU1rmNeNMGTCBbOAcJFKhAeZyddZxcU0trdy4bq6ai7p9PJJI4irxNPP3VtlPtXJYf83Wih4NGheChMqXht3XJ9Jl1ycD07MjE0FIL6rCm63RZOyEWLEvyvZwhWuLxM8AC6x26EGrVD+YGlcFI7vE1D7DKPpEqLBPVAjMZEKFOJ7xB+IqDa7K3Xj4OU2a5Vm1GKtotKEGuXohGKierRHRWgkIkb9WAn9Htvh0y0ixOt2iZ/3iL6W60FTIsaBzTovM/Lq19CNoLw9q/7n89xBYhT142KK59U3RWcYQMYZbBKvfdCGrV16p9GsZkO8knqYc+bYEeKWD/dbe1fdca+kD4aTlkEk8ykwcfh9qmlCUxqvqGaWwd8PLkqIYP"

	cipher, err := base64.StdEncoding.DecodeString(cipherBase64)
	if err != nil {
		t.Error(err)
	}

	plain, err := DecryptOAEPWithSha1(priKey, cipher)
	if err != nil {
		t.Error(err)
	}

	t.Log(string(plain))
}

func TestDecryptOAEPWithSha1AndEncoder(t *testing.T) {
	priKey, err := PemPrivateKey([]byte(privateKeyStr))
	if err != nil {
		t.Error(err)
	}

	plainText, err := DecryptOAEPWithSha1AndEncoder(priKey, "hrE2GQ0aoGnrbIdyUBX0dxKt1bvzbkP0ufWrIxf9YL4U7c8fdZxPmLIYJlgegUVtUJeEHy8qFKGXiP4gsmEMgnhaILPzrQlQQ8pWcqVsotHfOACrg+40TrXCNU/7VRAnbwRO6mfRDwhwICggoyhDzvd0pr2yV0A3MgQ5VwaL+tZkp9obVipmLYt5Vd873koNvv0yFJUo0CytvSen4TQ+XnFfykT5tG4hvCAjSgn5+1BFYw3ZKWW7yynk+aVRRElwAjyDi6LKhA0WF7hP4Do8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jRyofdnv6rE5tIY706/5YYAxT1VL03GUejtENneoMNiKSjLTrJjvd2Np2/PmU19uojwpZeEwGWf0clSsEOsPZhdx1YxT4/F4IfihWyuohAJVO3WmMyz1AXX2Lz+pgG9plYLL6R3Tn7mYVRHO7wKJWTdkSUAyC9uzimVR0cQwx1dGKIxc7QxrvmX+0yOUb1tHgMFCdyBrycNHKXgGQcKkQ1w2xVloVL1m75BFxXlyzF+RUtWhWCCVdJzaNkFK/8jAYlxKwj+CJnLlyVNh/spuJis74Bph9oaK4NQmAFIITtKUzcGgxhIpQ15bELpuE3r19BzW/0wRmRuW6QaVPGyHX+1eojo8WkRa9bHC5qKhk1ashEScYkhG/ilkeyufMDrr94TROyn0Bb16v55cMLZ9oTIiAgBm6k+/dvCGCbXblmuFLtSkKbED9aX7OcVRv2G22b8QpoK/gUQPACI4dwfQ9X7z9dc8F0/gq/A1Q6prS0nfHXBiMSieyWVjAIguqb0I1s0uRWGEYWVvXUGWM8Sgr4qDcxE9uzNigSosLlYayW8kdOCasldPMt6nFh2GPbMsyi9LI29uyt8HgQ2oIyz", &encoder.Base64Encoder)
	if err != nil {
		t.Error(err)
	}

	t.Log(string(plainText))
}
